class Solution {
public:
    int findMin(vector<int>& nums) {
        int left=0,right=nums.size()-1,mid=0,ans=INT_MAX;
        while(left<=right)
        {
            mid=left+(right-left)/2;
            if(nums[left]<=nums[mid]&&nums[mid]<=nums[right]) return nums[left];
            else if(nums[left]<=nums[mid])
                left=mid+1;
            else if(nums[mid]<=nums[right])
                right=mid;

        }
        return nums[-1];
    }
};
